package com.bestcem.xm.user.grpc.client.convert;

import com.bestcem.xm.om.grpc.v1.services.Package;
import com.bestcem.xm.user.grpc.client.convert.strategy.PackageGrpcConvertStrategy;
import com.bestcem.xm.user.grpc.client.dto.PackageDTO;
import com.bestcem.xm.user.util.business.mapstract.TransformStrategy;
import com.bestcem.xm.user.util.business.mapstract.TransformStrategyConstant;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;

/**
 * 套餐转换类
 *
 * @author wangyunyun <yunyun.wang@idiaoyan.com>
 * @version v1.0
 * @date 2022/6/20 12:44
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface PackageGrpcConvert extends PackageGrpcConvertStrategy, TransformStrategy {

    @Mapping(target = "packageId", source = "id")
    @Mapping(target = "memberIndividuQuota", source = "memberIndQuota")
    @Mapping(target = "type", source = "typeValue")
    @Mapping(target = "edition", source = "editionValue")
    @Mapping(target = "discountBeginTime", source = "discountBeginTime", qualifiedByName = TransformStrategyConstant.GRPC_TIMESTAMP_TO_DATE)
    @Mapping(target = "discountEndTime", source = "discountEndTime", qualifiedByName = TransformStrategyConstant.GRPC_TIMESTAMP_TO_DATE)
    PackageDTO packGrpc2Dto(Package pack);
}
